package com.lu.article.controller.v1;

import com.lu.article.service.ApArticleIndexService;
import com.lu.common.constants.ArticleContants;
import com.lu.model.article.dto.ArticleIndexDto;
import com.lu.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
@Api(value = "app端首页新闻列表", tags = "ap_article", description = "加载新闻列表")
public class ArticleIndexController {

    @Autowired
    private ApArticleIndexService apArticleIndexService;

    /**
     * 默认加载
     * @param dto
     * @return
     */
    @ApiOperation(value = "默认加载")
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleIndexDto dto) {
        return apArticleIndexService.loadIndexArticle(dto, ArticleContants.LOADTYPE_LOAD_MORE);
    }

    @ApiOperation(value = "上滑加载更多新闻")
    @PostMapping("/loadmore")
    public ResponseResult loadMore(@RequestBody ArticleIndexDto dto) {
        return apArticleIndexService.loadIndexArticle(dto, ArticleContants.LOADTYPE_LOAD_MORE);
    }

    @ApiOperation(value = "下滑加载最新新闻")
    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleIndexDto dto) {
        return apArticleIndexService.loadIndexArticle(dto, ArticleContants.LOADTYPE_LOAD_NEW);
    }
}
